package io.geekidea.springbootplus.system.service.impl;

import io.geekidea.springbootplus.system.entity.TaskTemp;
import io.geekidea.springbootplus.system.mapper.TaskTempMapper;
import io.geekidea.springbootplus.system.service.TaskTempService;
import io.geekidea.springbootplus.system.param.TaskTempPageParam;
import io.geekidea.springbootplus.system.vo.TaskTempQueryVo;
import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import io.geekidea.springbootplus.framework.core.pagination.PageInfo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.transaction.annotation.Transactional;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import java.io.Serializable;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;

import java.util.List;
/**
 *  服务实现类
 *
 * @author miko
 * @since 2020-12-27
 */
@Slf4j
@Service
public class TaskTempServiceImpl extends BaseServiceImpl<TaskTempMapper, TaskTemp> implements TaskTempService {

    @Autowired
    private TaskTempMapper taskTempMapper;

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean saveTaskTemp(TaskTemp taskTemp) throws Exception {
        return super.save(taskTemp);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean updateTaskTemp(TaskTemp taskTemp) throws Exception {
        return super.updateById(taskTemp);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean deleteTaskTemp(Long id) throws Exception {
        return super.removeById(id);
    }


    @Override
    public List<TaskTemp> getAllList(LambdaQueryWrapper<TaskTemp> wrapper) throws Exception{
        return taskTempMapper.selectList(wrapper);
    }



    @Override
    public TaskTempQueryVo getTaskTempById(Serializable id) throws Exception {
    return taskTempMapper.getTaskTempById(id);
    }

    @Override
    public Paging<TaskTempQueryVo> getTaskTempPageList(TaskTempPageParam taskTempPageParam) throws Exception {
        Page<TaskTempQueryVo> page = new PageInfo<>(taskTempPageParam, OrderItem.desc(getLambdaColumn(TaskTemp::getCreateTime)));
        IPage<TaskTempQueryVo> iPage = taskTempMapper.getTaskTempPageList(page, taskTempPageParam);
        return new Paging<TaskTempQueryVo>(iPage);
    }

}
